<template>
	<view class="content poRel">
		<view class="wid100 " :style="'background-image: url('+theme.my_back_img+');'"
			style="height: 422rpx;box-sizing: border-box;background-size: 100% 100%;">
			 <!-- 状态栏高度 -->
			<!-- #ifdef APP -->
			<view :style="{'height': geStatusBarHeight + 'px'}"></view>
			<view class="fowe600 coFFF dis disAl disJuC poRel" style="height: 44px;">
				<view class="poAbs hei100 dis disAl" style="top: 0;left: 20rpx;" @click="fanhui()">
					<uni-icons type="left" size="40rpx" color="#fff"></uni-icons>
				</view>
				<span>代理商端</span>
			</view>
			<view style="height: 50rpx;"></view>
			<!-- #endif -->
			
			<!-- #ifdef H5 -->
			<view style="height: 100rpx;"></view>
			<!-- #endif -->
			
			<view class="wid90 mar dis disAl disJuB">
				<view class="wid25" style="height: 138rpx;">
					<image :src="agent_info.avatar" class="borRad50"
						style="width: 130rpx;height: 130rpx;border: 4rpx solid #fff;"></image>
				</view>
				<view class="coFFF" style="width: 75%;">
					<view class="dis disAl disJuB">
						<view>
							<view class="foSi50 fowe600" style="line-height: 44rpx;">{{agent_info.agent.full_name}}</view>
							<view class="foSi30 mar-top15" style="line-height: 44rpx;">{{agent_info.mobile}}</view>
						</view>
						<image src="../../static/shezhi.png" @click="tiaozhuan('/pages/agent/install')" style="width: 30rpx;height: 30rpx;"></image>
					</view>
				</view>
			</view>
		</view>
		<view class="wid90 mar borRad20 bacFFF borRad20" style="box-shadow: 0rpx 5rpx 10rpx 0rpx rgba(0,0,0,0.1);margin-top: -100rpx;">
			<view class="wid90 mar" @click="tiaozhuan('/pages/agent/withdrawList')">
				<view style="height: 10rpx;"></view>
				<view class="dis disAl disJuB" style="padding: 20rpx 0;border-bottom: 1px solid #E5E5E5;">
					<view>
						<view class="foSi25" style="line-height: 41rpx;">可提现（元）</view>
						<view class="fowe600 mar-top20 foSi40" style="line-height: 41rpx;">{{agent_info.agent.money}}</view>
					</view>
					<view class="dis disAl disJuC foSi25 coFFF borRad40" :style="'background: '+theme.main_color+';'"
						style="width: 150rpx;height: 56rpx;" @click.stop="tiaozhuan('/pages/partner/withdraw?id='+0+'&shenfen=3')">我要提现</view>
				</view>
				<view class="dis disAl " style="height: 96rpx;line-height: 41rpx;">
					<view class="foSi25">待结算金额（元）</view>
					<view class="fowe600 mar-left20 foSi40">{{agent_info.agent.settlement}}</view>
				</view>
			</view>
		</view>
		<!-- <view class="borRad20 bacFFF wid90 mar mar-top20" style="padding: 30rpx 0;box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0,0,0,0.1);">
			<view class="wid90 mar dis disAl disJuB">
				<view class="dis disAl">
					<image src="../../static/bangdingjizhi.png" style="width: 94rpx;height: 94rpx;"></image>
					<view class="mar-left20">
						<view class="fowe800 foSi35" style="line-height: 40rpx;">绑定技师</view>
						<view class="foSi20 mar-top15" style="color: #737373;">整合自己的技师资源，获取分润</view>
					</view>
				</view>
				<view class="dis disAl disJuC borRad10 foSi25 coFFF" 
					style="width: 130rpx;height: 50rpx;background-color: #00C82D;">邀请Ta</view>
			</view>
		</view> -->
		<view class="borRad20 bacFFF wid90 mar mar-top30" style="padding: 30rpx 0;box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0,0,0,0.1);">
			<view class="wid90 mar">
				<view class="fowe800 foSi30" style="line-height: 40rpx;">智能助手</view>
				<view class="dis disAl disJuB mar-top20 hei60">
					<view class="dis disAl disJuC coFFF foSi22 fowe600"  :style="'background: '+theme.main_color+';'"
					style="width: 120rpx;height: 40rpx;border-radius: 5rpx;">订单通知</view>
					<view class="dis disAl disJuB" style="width: 77%;" v-if="Object.keys(assis_message).length > 0 && assis_message.order_msg">
						<view class="foSi25 fowe600">{{assis_message.order_msg.message_info}}</view>
						<view class="dis disAl foSi20" style="color: #8B8B8B;" @click="yidu('/pages/agent/indent?xuan=0',1)">
							<view class="mar-right10">点击查看</view>
							<uni-icons type="right" size="28rpx"></uni-icons>
						</view>
					</view>
					<view v-else class="foSi25 fowe600" style="width: 77%;">暂无数据</view>
				</view>
				<view class="dis disAl disJuB mar-top20 hei60">
					<view class="dis disAl disJuC coFFF foSi22 fowe600" style="width: 120rpx;height: 40rpx;background-color: #F19149;border-radius: 5rpx;">退款通知</view>
					<view class="dis disAl disJuB" style="width: 77%;" v-if="Object.keys(assis_message).length > 0 && assis_message.out_order_msg">
						<view class="foSi25 fowe600">{{assis_message.out_order_msg.message_info}}</view>
						<view class="dis disAl foSi20" style="color: #8B8B8B;" @click="yidu('/pages/agent/refund',2)">
							<view class="mar-right10">点击查看</view>
							<uni-icons type="right" size="28rpx"></uni-icons>
						</view>
					</view>
					<view v-else class="foSi25 fowe600" style="width: 77%;">暂无数据</view>
				</view>
				<view class="dis disAl disJuB mar-top20 hei60">
					<view class="dis disAl disJuC coFFF foSi22 fowe600" style="width: 120rpx;height: 40rpx;background-color: #FF0000;border-radius: 5rpx;">拒单通知</view>
					<view class="dis disAl disJuB" style="width: 77%;" v-if="Object.keys(assis_message).length > 0 && assis_message.refuse_order_msg">
						<view class="foSi25 fowe600">{{assis_message.refuse_order_msg.message_info}}</view>
						<view class="dis disAl foSi20" style="color: #8B8B8B;" @click="yidu('/pages/agent/indent?xuan=0',3)">
							<view class="mar-right10">点击查看</view>
							<uni-icons type="right" size="28rpx"></uni-icons>
						</view>
					</view>
					<view v-else class="foSi25 fowe600" style="width: 77%;">暂无数据</view>
				</view>
			</view>
		</view>
		
		<view class="wid87 mar mar-top20" style="height: 172rpx;" @click="tiaozhuan('/pages/partner/technicianInvit')">
			<image src="../../static/yaoxin2.png" class="wh100"></image>
		</view>
		
		<view class="wid90 mar bacFFF borRad20 mar-top20" style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0,0,0,0.1);">
			<view style="height: 30rpx;"></view>
			<view class="wid90 mar">
				<view class="fowe800 foSi30" style="line-height: 40rpx;">更多功能</view>
				<view class="dis disAl flwa">
					<view class="wid25 textCen mar-top30" @click="tiaozhuan('/pages/agent/indent')">
						<view class="wid100 dis disAl disJuC" style="height: 70rpx;">
							<uni-icons custom-prefix="iconfont" size="50rpx" :color="theme.main_color"
								type="icon-dingdanguanli"></uni-icons>
						</view>
						<!-- <view class="mar" style="width: 70rpx;height: 70rpx;">
							<image src="../../static/jishijiedan1.png" class="wh100"></image>
						</view> -->
						<view class="foSi20 mar-top10 fowe600">订单管理</view>
					</view>
					<view class="wid25 textCen mar-top30" @click="tiaozhuan('/pages/agent/bellAdd')">
						<view class="wid100 dis disAl disJuC" style="height: 70rpx;">
							<uni-icons custom-prefix="iconfont" size="50rpx" :color="theme.main_color"
								type="icon-shijianguanli1"></uni-icons>
						</view>
						<!-- <view class="mar" style="width: 70rpx;height: 70rpx;">
							<image src="../../static/daifuwu2.png" class="wh100"></image>
						</view> -->
						<view class="foSi20 mar-top10 fowe600">加钟管理</view>
					</view>
					<!-- <view class="wid25 textCen mar-top30" @click="tiaozhuan('/pages/agent/rejectSingle')">
						<view class="wid100 dis disAl disJuC" style="height: 70rpx;">
							<uni-icons custom-prefix="iconfont" size="50rpx" :color="theme.main_color"
								type="icon-judan"></uni-icons>
						</view>
						<view class="mar" style="width: 70rpx;height: 70rpx;">
							<image src="../../static/daizhuandan.png" class="wh100"></image>
						</view>
						<view class="foSi20 mar-top10 fowe600">拒单管理</view>
					</view> -->
					<view class="wid25 textCen mar-top30" @click="tiaozhuan('/pages/agent/refund?ty=0')">
						<view class="wid100 dis disAl disJuC" style="height: 70rpx;">
							<uni-icons custom-prefix="iconfont" size="50rpx" :color="theme.main_color"
								type="icon-fuwutuikuan"></uni-icons>
						</view>
						<!-- <view class="mar" style="width: 70rpx;height: 70rpx;">
							<image src="../../static/tixian1.png" class="wh100"></image>
						</view> -->
						<view class="foSi20 mar-top10 fowe600">服务退款</view>
					</view>
					<view class="wid25 textCen mar-top30" @click="tiaozhuan('/pages/agent/refund?ty=1')">
						<view class="wid100 dis disAl disJuC" style="height: 70rpx;">
							<uni-icons custom-prefix="iconfont" size="50rpx" :color="theme.main_color"
								type="icon-20150619055659533easyiconnet"></uni-icons>
						</view>
						<!-- <view class="mar" style="width: 70rpx;height: 70rpx;">
							<image src="../../static/jujuetuikuan1.png" class="wh100"></image>
						</view> -->
						<view class="foSi20 mar-top10 fowe600">加钟退款</view>
					</view>
					<view class="wid25 textCen mar-top30" @click="tiaozhuan('/pages/agent/install')">
						<view class="wid100 dis disAl disJuC" style="height: 70rpx;">
							<uni-icons custom-prefix="iconfont" size="50rpx" :color="theme.main_color"
								type="icon-guanliyemian--zhanghaoshezhi-zhanghaoshezhi"></uni-icons>
						</view>
						<!-- <view class="mar" style="width: 70rpx;height: 70rpx;">
							<image src="../../static/shezhi1.png" class="wh100"></image>
						</view> -->
						<view class="foSi20 mar-top10 fowe600">账号设置</view>
					</view>
					<view class="wid25 textCen mar-top30" @click="tiaozhuan('/pages/agent/technician')">
						<view class="wid100 dis disAl disJuC" style="height: 70rpx;">
							<uni-icons custom-prefix="iconfont" size="50rpx" :color="theme.main_color"
								type="icon-tech"></uni-icons>
						</view>
						<!-- <view class="mar" style="width: 70rpx;height: 70rpx;">
							<image src="../../static/jishiguanli1.png" class="wh100"></image>
						</view> -->
						<view class="foSi20 mar-top10 fowe600">技师管理</view>
					</view>
					<view class="wid25 textCen mar-top30" @click="tiaozhuan('/pages/agent/brokerageDetail')">
						<view class="wid100 dis disAl disJuC" style="height: 70rpx;">
							<uni-icons custom-prefix="iconfont" size="50rpx" :color="theme.main_color"
								type="icon-for-close-account"></uni-icons>
						</view>
						<!-- <view class="mar" style="width: 70rpx;height: 70rpx;">
							<image src="../../static/yongjin1.png" class="wh100"></image>
						</view> -->
						<view class="foSi20 mar-top10 fowe600">佣金信息</view>
					</view>
				</view>
			</view>
			<view style="height: 30rpx;"></view>
		</view>
		<view style="height: 50rpx;"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: this.global.url,
				theme: null,
				agent_info:{}, // 代理商首页数据
				assis_message:{}, // 代理商助手消息
			}
		},
		onShow() {
			this.get_agent_info()
			this.get_assis_message()
		},
		onLoad(option) {
			uni.setStorageSync('distr_agent','agent');
			this.theme = uni.getStorageSync('theme')
		},
		methods: {
			yidu(url,type){
				let that = this
				uni.showLoading({
					title:'加载中...'
				})
				uni.request({
					url: that.global.url + 'api/qianyu_smfw/agent/assis_message_read',
					method: "POST",
					header: {
						'site-id': that.global.site_id, //自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						agent_id:uni.getStorageSync('agent_id'),
						type:type
					},
					success(res) {
						let result = res.data
						console.log(result.data)
						if (result.code == 1) {
							uni.navigateTo({
								url:url
							})
						} else {
							uni.showToast({
								title: result.msg,
								//将值设置为 success 或者直接不用写icon这个参数
								icon: 'error',
								//显示持续时间为 2秒
								duration: 2000
							})
						}
					},complete() {
						uni.hideLoading()
					}
				})
			},
			get_assis_message(){
				let that = this
				uni.showLoading({
					title:'加载中...'
				})
				uni.request({
					url: that.global.url + 'api/qianyu_smfw/agent/assis_message',
					method: "POST",
					header: {
						'site-id': that.global.site_id, //自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						agent_id:uni.getStorageSync('agent_id')
					},
					success(res) {
						let result = res.data
						console.log(result.data)
						if (result.code == 1) {
							// that.agent_info = result.data
							that.assis_message = result.data
						} else {
							uni.showToast({
								title: result.msg,
								//将值设置为 success 或者直接不用写icon这个参数
								icon: 'error',
								//显示持续时间为 2秒
								duration: 2000
							})
						}
					},complete() {
						uni.hideLoading()
					}
				})
			},
			
			get_agent_info(){
				let that = this
				uni.showLoading({
					title:'加载中...'
				})
				uni.request({
					url: that.global.url + 'api/qianyu_smfw/agent/index',
					method: "POST",
					header: {
						'site-id': that.global.site_id, //自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						agent_id:uni.getStorageSync('agent_id')
					},
					success(res) {
						let result = res.data
						console.log(result.data)
						if (result.code == 1) {
							that.agent_info = result.data
						} else {
							uni.showToast({
								title: result.msg,
								//将值设置为 success 或者直接不用写icon这个参数
								icon: 'error',
								//显示持续时间为 2秒
								duration: 2000
							})
						}
					},complete() {
						uni.hideLoading()
					}
				})
			},
			
			
			
			
			// 获取状态栏高度
			geStatusBarHeight() {
				return uni.getSystemInfoSync()['statusBarHeight']
			},
			fanhui(){
				uni.navigateBack(1)
			},
			tiaozhuan(url) {
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style>
	.content {
		min-height: 100vh;
		background-color: #F2F2F2;
	}
</style>